<?php
class WumiiJianWidget extends CWidget{
	private $outString;
	private $action;
	public $url;//文章链接
	public $title; //文章标题
	public $tag; //文章标签
	public $category;//文章分类
	private $domain;
	

	public function init(){
		//$this->controller = Yii::app()->controller->id;  
        $this->action = Yii::app()->controller->action->id;
        $this->title = json_encode($this->title);
        $this->category = json_encode(array("{$this->category}"));
        $this->tag = json_encode($this->tag);
        $this->domain = Yii::app()->request->hostInfo;
	}

	public function run(){
		$this->tuijian();
		echo $this->outString;
	}

	public function tuijian(){
		$this->outString = <<<TUIJIAN
<!-- Wumii Jian BEGIN -->
<script type="text/javascript" id="wumiiRelatedItems"></script>
<script type="text/javascript">
    var wumiiPermaLink = "{$this->url}"; //请用代码生成文章永久的链接
    var wumiiTitle = {$this->title}; //请用代码生成文章标题
    var wumiiTags = {$this->tag}; //请用代码生成文章标签，以英文逗号分隔，如："标签1,标签2"
    var wumiiCategories = {$this->category}; //请用代码生成文章分类，分类名放在 JSONArray 中，如: ["分类1", "分类2"]
    var wumiiSitePrefix = "{$this->domain}";
    var wumiiParams = "&num=5&mode=2&pf=JAVASCRIPT";
</script>
<script type="text/javascript" src="http://widget.wumii.cn/ext/relatedItemsWidget"></script>
<a href="http://www.wumii.com/widget/relatedItems" style="border:0;"><!-- Wumii Jian END -->
TUIJIAN;
	
	}


}
?>
